import java.util.ArrayList;
import java.util.HashMap;

public class Node {
	private String leaf;
	private int attribute;
	private ArrayList<String> values;
	private HashMap<String,Node> children;

	/*
	 *  Non leaf node constructor
	 */
	public Node(int attribute) {
		this.attribute = attribute;		
		this.values = new InitialAttribute().getAttributeValue().get(attribute);	
		children = new HashMap<String,Node>();
	}
	
	/*
	 *  Leaf node constructor
	 */
	public Node(String leaf){
		this.attribute = InitialAttribute.Class;
		this.leaf = leaf;
		this.values = null;
		this.children = null;
	}
	
	/**
	 * This is the method to link parent node with child node
	 * value: indicate which way will go to child node
	 * attribute: the attribute of child node
	 * @param value 
	 * @param attribute
	 * @return
	 */
	public Node setChildNode(String value,int attribute){
		Node newNode = new Node(attribute);
		children.put(value, newNode);
		return newNode;
	}
	
	/**
	 * This is the method to link parent node with leaf node
	 * value: indicate which way will go to leaf node
	 * Class: which class the leaf node belongs to
	 * @param Class
	 * @param value
	 * @return
	 */
	public Node setLeafNode(String Class,String value){
		Node leafNode = new Node(Class);
		children.put(value, leafNode);
		return leafNode;
	}
	
	public Integer getAttribute(){
		return attribute;
	}
	
	public ArrayList<String> getValues(){
		return values;
	}
	
	public Node getChildNode(String value){
		return children.get(value);
	}
	
	/*
	 * To get the leaf node, if it is leaf node
	 */
	public String getLeafNode(){
		return leaf;
	}
	
}
